package pzl.com.transitionsframework;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class Activity2 extends AppCompatActivity {
    View tranCiv;
    View tranLl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_2);

        tranCiv = findViewById(R.id.c2);
        tranLl = findViewById(R.id.llItem2);
    }

    public void startActivityBySceneTransition() {
        List<Pair<View, String>> pairs = new ArrayList<>();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
          //  pairs.add(Pair.create(tranCiv, tranCiv.getTransitionName()));
            pairs.add(Pair.create(tranLl, tranLl.getTransitionName()));
        }
        Intent intent = new Intent(this, Activity3.class);
        ActivityOptionsCompat compat = ActivityOptionsCompat
                .makeSceneTransitionAnimation(this, pairs.toArray(new Pair[pairs.size()]));
        ActivityCompat.startActivity(this, intent, compat.toBundle());
    }

    public void click(View view) {
        startActivityBySceneTransition();
    }

}
